package com.yx.yinshanjinniu.utils;

import android.content.Context;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;

/**
 * 网络相关工具类
 */
public class NetCheckUtil {
    /**
     * 是否有网络连接
     * @param context
     * @return
     */
    public static boolean isNetConnected(Context context) {
        ConnectivityManager mConnectivityManager = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE);
        if (mConnectivityManager != null){
            NetworkInfo mNetworkInfo = mConnectivityManager.getActiveNetworkInfo();
            return (mNetworkInfo != null) && (mNetworkInfo.isConnectedOrConnecting());
        }
        return false;
    }

}
